;;; vim
;; evil
(use-package evil
  :ensure t
  :defer 1
  :config
  (evil-mode 1)
  (define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char)
  (define-key evil-normal-state-map (kbd "C-r") 'undo-redo))
;; (defun my/repeat-find-char ()
;;   ",to; ."
;;   (interactive)
;;   (evil-repeat-find-char 1))
(global-set-key [remap evil-repeat-find-char-reverse] #'evil-repeat-find-char)
;;evil-easymotion
(use-package evil-easymotion
  :ensure t
  :defer 3
  :config
  (evilem-default-keybindings "SPC"))
(global-set-key (kbd "C-c C-j" ) 'evilem-motion-next-line-first-non-blank)
(global-set-key (kbd "C-c C-k" ) 'evilem-motion-previous-line-first-non-blank)
;; evil-surround
(use-package evil-surround
  :ensure t
  :config
  (global-evil-surround-mode 1)
  :hook (evil-mode . evil-surround-mode))
(defun my/next-3-line ()
  "光标向下移动三行."
  (interactive)
  (forward-line 4))
(global-set-key [remap evil-join] #'my/next-3-line)

(defun my/previous-3-line ()
  "光标向上移动三行."
  (interactive)
  (forward-line -4))
(global-set-key [remap evil-lookup] #'my/previous-3-line)
;; evil-nerd-commenter
(use-package evil-nerd-commenter
  :after evil-mode)
;; evil-leader
(use-package evil-leader
  :ensure t
  :defer 3
  :config (global-evil-leader-mode)
  :hook
  (evil-mode . evil-leader-mode)
  :custom ((evil-leader/leader ";")
	   ;;(evil-leader/in-all-states t))
	   (evil-leader/no-prefix-mode-rx '(".*")))
  :config
  (evil-leader/set-key
    "ci" 'evilnc-comment-or-uncomment-lines
    "mg" 'magit-status
    "nb" 'next-buffer
    "pb" 'previous-buffer
    "di" 'dirvish
    "md" 'bookmark-delete
    "ms" 'counsel-bookmark
    "yt" 'yas-describe-tables
    "ys" 'yas-new-snippet
    "si" 'swiper-isearch
    "ca" 'org-agenda
    "ff" 'find-file
    "w" 'save-buffer
    "q" 'save-buffers-kill-terminal
    "sb" 'ibuffer
    ";" 'quoted-insert
    "j" 'evil-normal-state))


(provide 'init-evil)
;;; init-evil.el ends here
